package com.ylp.sys.mapper;

import com.ylp.sys.domain.entity.SysUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 系统用户表 Mapper 接口
 * </p>
 *
 * @author cc
 * @since 2024-07-24
 */
public interface SysUserMapper extends BaseMapper<SysUser> {
    /**
     * 根据用户id获取权限咧列表
     * @param id
     * @return
     */
    @Select("SELECT m.perms FROM sys_user u JOIN sys_user_role ur ON u.id = ur.user_id " +
            "JOIN sys_role_menu rm ON ur.role_id = rm.role_id " +
            "JOIN sys_menu m ON rm.menu_id = m.id where u.id = #{id};")
    List<String> selectPermsByUserId(@Param("id")Long id);

    @Select("SELECT r.role_label from sys_user_role ur JOIN sys_role r ON ur.role_id = r.id WHERE ur.user_id = #{id}")
    List<String> selectRoleLabelByUserId(@Param("id") Long id);

}
